//
//  ZDAlertController.m
//  ZDPension
//
//  Created by 刘甲奇 on 2017/6/16.
//  Copyright © 2017年 maker. All rights reserved.
//

#import "ZDAlertController.h"
#import "ZDAlertSheetView.h"
#import "ZDTitleContentAlertView.h"

@interface ZDAlertController ()

/**
 选中的索引
 0---点击了空白取消
 1---到点消费
 2---上门服务
 */
@property (nonatomic,assign) NSInteger selectIndex;


@end

@implementation ZDAlertController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.08];
    self.modalPresentationStyle = UIModalPresentationCustom;
    
}

/**
 竖排按钮的提示 view
 */
- (void)showSheetView
{
    CGFloat padding = 30;
    
    ZDAlertSheetView *sheetView = (ZDAlertSheetView *)[UIView getNibView:@"ZDAlertSheetView"];
    [self.view addSubview:sheetView];
    sheetView.bounds = CGRectMake(0, 0, LEScreenWidth -2*padding, 210);
    sheetView.center = self.view.center;
     __weak typeof (self) weakSelf = self;
    [sheetView alertButtonClick:^(NSInteger tag) {
        ZDLog(@"%s---%d---%ld",__func__,__LINE__,tag);
        weakSelf.selectIndex = tag;
        [weakSelf dismissViewControllerAnimated:YES completion:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:SELECT_PAYTYPE object:@(self.selectIndex)];
    }];
}
- (void)showAlertTitle:(NSString *)title content:(NSString *)content clickBlock:(alertButonClickBlock) block
{
    
    CGFloat padding = 30;
    
    ZDTitleContentAlertView *titleView = (ZDTitleContentAlertView *)[UIView getNibView:@"ZDTitleContentAlertView"];
    titleView.bounds = CGRectMake(0, 0, LEScreenWidth -2*padding, 180);
    titleView.center = self.view.center;
    [titleView showAlertTitle:title content:content clickBlock:block];
    [self.view addSubview:titleView];
    [titleView layoutIfNeeded];

}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end









